       SUBROUTINE RAD_MPI(rg,rat,pl,xrg,xra,xpl &
       & ,nx,ny,ndados,nf,dtl,n,xugeos,xvgeos,ugeos,vgeos,ns,zonirr)
!
! updates radiation forcing at the surface (linear time interpolation)
!
       use MPI_VARIABLES, only : &
       & nxs2i, nxs2e, nys2i, nys2e, &
       & nxi, nxe, nyi, nye

       implicit none

       real(8), intent(out) :: rg(nxs2i:nxs2e,nys2i:nys2e)
       real(8), intent(out) :: rat(nxs2i:nxs2e,nys2i:nys2e)
       real(8), intent(out) :: pl(nxs2i:nxs2e,nys2i:nys2e)

       real(8), intent(in) :: xrg(0:ndados)
       real(8), intent(in) :: xra(0:ndados)
       real(8), intent(in) :: xpl(0:ndados)
       real(8), intent(in) :: zonirr(nxs2i:nxs2e,nys2i:nys2e)

       real(8), intent(in) :: xugeos(1:ns,1:5), xvgeos(1:ns,1:5)
       real(8), intent(in) :: ugeos(1:ns), vgeos(1:ns)

       real(8), intent(in) :: dtl

       integer(4), intent(in) :: nx, ny, ns
       integer(4), intent(in) :: ndados, nf, n

!      Local variables
       integer :: izx, izzx
       integer :: ix, iy


        izx = int(n * dtl/ nf + 1.)
        izzx = int(n * dtl - nf * izx + nf)

!       write(*,*) 'izx=',izx,ndados
        if(izx.ge.ndados) then
          write(0,*) 'nh3dFatalError=Not enough radiation data !'
          STOP
        endif

        do ix = nxi, nxe !11, nx
          do iy = nyi, nye !1, ny
            rat(ix,iy) = xra(izx) + (xra(izx+1) - xra(izx))*float(izzx)/float(nf)
            pl(ix,iy) = (xpl(izx) + (xpl(izx+1) - xpl(izx))*float(izzx)/float(nf)) &
            & *zonirr(ix,iy)
            rg(ix,iy) = xrg(izx) + (xrg(izx+1) - xrg(izx))*float(izzx)/float(nf)
          enddo
        enddo



!  update of geostrophic wind (note only for fcori.ne.0)
!
!       izx = int(n * dtl/12./ nf + 1.)
!       izzx = int(n * dtl - nf*12 * izx + nf*12)
!       do 104 is=1,ns-1
!          ugeos(is)=xugeos(is,izx)+(xugeos(is,izx+1)-xugeos(is,izx))
!    &     *izzx/12./nf
!          vgeos(is)=xvgeos(is,izx)+(xvgeos(is,izx+1)-xvgeos(is,izx))
!    &     *izzx/12./nf
!       write(28,*) 'ug,uv',ugeos(is),vgeos(is)
!104    continue


!       call wrigar(rat,1,nx,1,ny,0,0,1,nx,1,ny,0,0,'rat     ',0.d0,1)
!       call wrigar(rg,1,nx,1,ny,0,0,1,nx,1,ny,0,0,'rg      ',0.d0,1)
!       call wrigar(pl,1,nx,1,ny,0,0,1,nx,1,ny,0,0,'pl      ',0.d0,1)
!
!      do igeo=1,ns-1
!          write(*,*) 'vgeo',igeo,ugeos(igeo),vgeos(igeo)
!       enddo



        return
        END SUBROUTINE RAD_MPI
